<?php

class NoticiasController extends AppController {

    public $sl_noticias = array(
        "actions" => array("V" => "view", "E" => "edit", "D" => "delete"),
        "filters" => array(
            array('name' => 'Noticia.titulo', 'label' => 'Tìtulo')
        ),
        "columns" => array(
            array('name' => 'Noticia.id', 'label' => 'Número')
        )
    );
    public $maint_noticias = array(
        "fields" => array(
            "Descripción de la Noticia" =>
            array(
                array("name" => "fecha", "label" => "Fecha", "presentation" => "DATETIME", 'classparams' => '{"force":true}', 'isvisible' => false, "actions" => "A"),
                array("name" => 'titulo', "label" => 'Título', 'size' => '78'),
                array("name" => 'volanta', "label" => 'Volanta', 'size' => '78'),
                array("name" => 'copete', "label" => 'Copete', 'presentation' => 'TEXTAREA'),
                array("name" => 'cuerpo', "label" => 'Cuerpo', 'presentation' => 'TEXTAREA'),
                array("name" => 'imagen', "label" => 'Imagen', 'presentation' => 'FILE')
            )
        )
    );
    
    public function beforeFilter() {
        parent::beforeFilter();
        $this->Auth->allow('leer');
    }
    
    public function leer($id = null) {
        
    }

    public function add() {
        $this->layout = "admin";
        $this->maint = $this->maint_noticias;
        parent::add();
    }

    public function edit($id = null) {
        $this->layout = "admin";
        $this->maint = $this->maint_noticias;
        parent::edit($id);
    }

    public function index() {
        $this->layout = "admin";
        $this->search_list = $this->sl_noticias;
        parent::index();
    }

    public function view($id = null) {
        $this->Noticia->id = $id;
        if (!$this->$model->exists()) {
            throw new NotFoundException(__('Registro inexistente'));
        }
        
        $this->layout = "admin";
        $this->maint = $this->maint_noticias;
        parent::view($id);
    }

}